package com.monlyu.action.voice;

import java.util.Date;

import com.monlyu.action.PageAction;
import com.monlyu.annotation.ActionAnno;
import com.monlyu.bean.Pages;
import com.monlyu.bo.VoiceBo;
import com.monlyu.vo.Manuscript;
import com.monlyu.vo.Voice;

/**
 * @since Ma Yanna 2010-3-1
 */
public class EditVoiceAction extends PageAction {
	private Date beginDate;
	private Date endDate;
	private VoiceBo voiceBo;
	private Voice voice;
	private Long id;

	public void setId(Long id) {
		this.id = id;
	}

	public Voice getVoice() {
		return voice;
	}

	private Pages<Manuscript> manuscripts;
	private Manuscript manuscript;

	public Manuscript getManuscript() {
		return manuscript;
	}

	public void setManuscript(Manuscript manuscript) {
		this.manuscript = manuscript;
	}

	public void setManuscripts(Pages<Manuscript> manuscripts) {
		this.manuscripts = manuscripts;
	}

	public String toEdit() {
		return view("voiceForm.jsp");
	}

	public Pages<Manuscript> getManuscripts() {
		return manuscripts;
	}

	public void setVoiceBo(VoiceBo voiceBo) {
		this.voiceBo = voiceBo;
	}

	@Override
	@ActionAnno(readOnly = true)
	public String execute() throws Exception {
		manuscripts = voiceBo.findManuscript(manuscript, beginDate, endDate, getDefPage());
		return view("voiceForm.jsp");
	}

	public String voice() {
		voiceBo.addVoice(manuscript);
		return ajax(manuscript.getId());
	}

	/** 获取内容 */
	public String getContent() {
		return ajax(voiceBo.getContent(id));
	}

	public Date getBeginDate() {
		return beginDate;
	}

	public void setBeginDate(Date beginDate) {
		this.beginDate = beginDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}
}
